package com.blb.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blb.dto.EmpDTO;
import com.blb.dto.Page1DTO;
import com.blb.dto.PageDTO;
import com.blb.entity.Emp;
import com.blb.service.EmpService;
import com.blb.vo.PageAble;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
public class EmpController {

    @Autowired
    private EmpService empService;


    //添加员工
    @PostMapping("insert")
    public boolean addEmp(@RequestBody Emp emp){
        return empService.addEmp(emp);
    }

    //修改员工
    @PutMapping("update")
    public boolean updateEmp(@RequestBody Emp emp){
        return empService.updateById(emp);
    }

    //删除员工
    @GetMapping("delete/{id}")
    public boolean deleteEmp(@PathVariable Integer id){
        return empService.removeById(id);
    }



    //查询所有员工
    @GetMapping("getAllEmp")
    public List<EmpDTO> getByName(PageAble pageAble,String username, String det){
        return empService.getByName(pageAble,username,det);
    }

    @GetMapping("selectList")
    public void selectList(Page1DTO page1DTO){
        System.out.println("hello");
    }

}
